package com.ruoyi.web.controller.platform;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.platform.domain.MMonitoringEquipment;
import com.ruoyi.platform.service.IMMonitoringEquipmentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 【监控设备】Controller
 * 
 * @author dataControl
 * @date 2025-09-15
 */
@RestController
@RequestMapping("/platform/equipment")
public class MMonitoringEquipmentController extends BaseController
{
    @Autowired
    private IMMonitoringEquipmentService mMonitoringEquipmentService;

    /**
     * 查询【监控设备】列表
     */
    @PreAuthorize("@ss.hasPermi('platform:equipment:list')")
    @GetMapping("/list")
    public TableDataInfo list(MMonitoringEquipment mMonitoringEquipment)
    {
        startPage();
        List<MMonitoringEquipment> list = mMonitoringEquipmentService.selectMMonitoringEquipmentList(mMonitoringEquipment);
        return getDataTable(list);
    }

    /**
     * 导出【监控设备】列表
     */
    @PreAuthorize("@ss.hasPermi('platform:equipment:export')")
    @Log(title = "【导出【监控设备】列表】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MMonitoringEquipment mMonitoringEquipment)
    {
        List<MMonitoringEquipment> list = mMonitoringEquipmentService.selectMMonitoringEquipmentList(mMonitoringEquipment);
        ExcelUtil<MMonitoringEquipment> util = new ExcelUtil<MMonitoringEquipment>(MMonitoringEquipment.class);
        util.exportExcel(response, list, "【监控设备】数据");
    }

    /**
     * 获取【监控设备】详细信息
     */
    @PreAuthorize("@ss.hasPermi('platform:equipment:query')")
    @GetMapping(value = "/{equipmentId}")
    public AjaxResult getInfo(@PathVariable("equipmentId") Long equipmentId)
    {
        return success(mMonitoringEquipmentService.selectMMonitoringEquipmentByEquipmentId(equipmentId));
    }

    /**
     * 新增【监控设备】
     */
    @PreAuthorize("@ss.hasPermi('platform:equipment:add')")
    @Log(title = "获取【监控设备】详细信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MMonitoringEquipment mMonitoringEquipment)
    {
        return toAjax(mMonitoringEquipmentService.insertMMonitoringEquipment(mMonitoringEquipment));
    }

    /**
     * 修改【监控设备】
     */
    @PreAuthorize("@ss.hasPermi('platform:equipment:edit')")
    @Log(title = "修改【监控设备】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MMonitoringEquipment mMonitoringEquipment)
    {
        return toAjax(mMonitoringEquipmentService.updateMMonitoringEquipment(mMonitoringEquipment));
    }

    /**
     * 删除【监控设备】
     */
    @PreAuthorize("@ss.hasPermi('platform:equipment:remove')")
    @Log(title = "删除【监控设备】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{equipmentIds}")
    public AjaxResult remove(@PathVariable String[] equipmentIds)
    {
        return toAjax(mMonitoringEquipmentService.deleteMMonitoringEquipmentByEquipmentIds(equipmentIds));
    }
}
